//统一管理咱们项目用户相关的接口
import request from '@/util/request.ts'
import type {
  loginFormData,
  loginResponseData,
  userInfoReponseData,
} from './type'
//项目用户相关的请求地址
enum API {
  LOGIN_URL = '/user/login',
  REGISTER_URL = '/user/register',
  LOGIN_FACE_URL = '/user/login/detectFaces',
  USERINFO_URL = '/user/info',
  USER_INFO_DETAIL_URL = '/user/userInfo',
  LOGOUT_URL = '/user/logout',
  heartbeat_URL = '/user/heartbeat',
}

//登录接口
export const reqLogin = (data: loginFormData) =>
  request.post<any, loginResponseData>(API.LOGIN_URL, data)

//注册接口
export const reqRegister = (data) =>
  request.post<any, loginResponseData>(API.REGISTER_URL, data)

//人脸登录接口
export const reqLoginFace = (data) =>
  request.post<any, loginResponseData>(API.LOGIN_FACE_URL, data)

//获取用户信息
export const reqUserInfo = (data) => {
  return  request.get(API.USERINFO_URL, data )
}

//获取用户超详细信息
export const reqUserInfoDetail = (data) => {
  return  request.get(API.USER_INFO_DETAIL_URL + '/' + data)
}

//心跳检测
export const reqHeartbeat = () => {
  return  request.get(API.heartbeat_URL)
}

//退出登录
export const reqLogout = () => request.post<any, any>(API.LOGOUT_URL)
